package cn.jdx.tools.zip;

import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;

import java.io.File;

public class UnZipFile {
    public static void unzip(String outputPath) {
        try {
            System.out.println("[输入zip文件路径]:"+outputPath);
            ZipFile zipFile = new ZipFile(outputPath);
            //(2)输出
            File zipFileFile = new File(outputPath);
            File zipFileParent = new File(outputPath).getParentFile();
            String outputDirName = zipFileFile.getName().replaceAll(".zip", "");
            String outputDir = new File(zipFileParent.getAbsolutePath(),outputDirName).getAbsolutePath();
            System.out.println("[输出zip文件路径]:"+outputDir);
            zipFile.extractAll(outputDir);
        } catch (ZipException e) {
            System.err.println("文件解压异常:"+e);
        }
    }
}
